package cn.sinata.wanglin.adapter;

import android.view.View;

import com.facebook.drawee.view.SimpleDraweeView;
import com.xilada.xldutils.adapter.HFRecyclerAdapter;
import com.xilada.xldutils.adapter.util.ViewHolder;

import java.util.List;

import cn.sinata.wanglin.R;
import cn.sinata.wanglin.db.model.User;
import cn.sinata.wanglin.utils.ImageUtil;

/**
 *
 * Created by liaoxiang on 17/1/2.
 */

public class SelectUserAdapter extends HFRecyclerAdapter<User> {
    public SelectUserAdapter(List<User> mData) {
        super(mData, R.layout.item_select_user);
    }

    @Override
    public void onBind(int position, final User user, ViewHolder holder) {
        SimpleDraweeView headView = holder.bind(R.id.headView);
        headView.setImageURI(ImageUtil.parseImageUri(user.getHeadUrl()));
        holder.setText(R.id.tv_name,user.getName());
        View tv_select = holder.bind(R.id.tv_select);
        tv_select.setSelected(user.isSelect());
        tv_select.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                boolean isSelected = v.isSelected();
                user.setSelect(!isSelected);
                notifyDataSetChanged();
            }
        });
    }
}
